#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<assert.h>

char* My_strncpy(char* dest,const char* src, size_t n)
{
	assert(dest && src);
	char* ret = dest;
	while (n--)
	{
		if (*src != '\0')
		{
			*dest = *src;
			dest++;
			src++;
		}
		else
		{
			*dest = '\0';
			dest++;
		}
	}
	return ret;
}


int main()
{
	char str1[] = "abcdef";
	char str2[20] = { "xxxxxxxxxxxxxxxxxx"};
	My_strncpy(str2, str1, 8);
	printf("%s\n", str2);
}